package com.zhifa.hdtyg_cdgl.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
public class SiteMainPageController {

    @RequestMapping("/site/createtree")
    @ResponseBody
    public String createMenu(HttpSession httpSession){
        String userName = (String) httpSession.getAttribute("siterole");
        String menuJsonArray = "";

        if (userName.equals("manager")) {
            menuJsonArray="[{\"id\":1,\"text\":\"场地信息模块\",\"state\":\"closed\",\"iconCls\":\"icon-home\",\"attributes\":{},\n" +
                    "\"children\":[\n" +
                    "{\"id\":3,\"text\":\"场地信息管理\",\"state\":\"open\",\"iconCls\":\"icon-userManage\",\"attributes\":{\"authPath\":\"site_management.html\"}},\n" +
                    "\n" +
                    "{\"id\":3,\"text\":\"租借记录管理\",\"state\":\"open\",\"iconCls\":\"icon-userManage\",\"attributes\":{\"authPath\":\"site_yuyueguanli.html\"}},\n" +
                    "{\"id\":3,\"text\":\"维修管理\",\"state\":\"open\",\"iconCls\":\"icon-userManage\",\"attributes\":{\"authPath\":\"site_weixiuguanli.html\"}}" +
                    "]}]\n";
        } else {
            menuJsonArray="[{\"id\":1,\"text\":\"场地信息模块\",\"state\":\"closed\",\"iconCls\":\"icon-home\",\"attributes\":{},\n" +
                    "\"children\":[\n" +
                    "{\"id\":3,\"text\":\"场地信息\",\"state\":\"open\",\"iconCls\":\"icon-userManage\",\"attributes\":{\"authPath\":\"site_informationCommon.html\"}},\n" +
                    "\n" +
                    "{\"id\":3,\"text\":\"我的预约记录\",\"state\":\"open\",\"iconCls\":\"icon-userManage\",\"attributes\":{\"authPath\":\"site_wodeyuyue.html\"}}]}]\n";

        }
        return menuJsonArray;
    }
}
